home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2007 September / PCWSEP07.iso / Software / Linux / Linux Mint 3.0 Light / LinuxMint-3.0-Light.iso / casper / filesystem.squashfs / var / lib / dpkg / info / udev.preinst < prev    next >
Encoding:
Text File  |  2007-04-10  |  2.2 KB  |  90 lines

  1. #!/bin/sh -e
  2. # This script can be called in the following ways:
  3. #
  4. # Before the package is installed:
  5. #    <new-preinst> install
  6. #
  7. # Before removed package is upgraded:
  8. #    <new-preinst> install <old-version>
  9. #
  10. # Before the package is upgraded:
  11. #    <new-preinst> upgrade <old-version>
  12. #
  13. #
  14. # If postrm fails during upgrade or fails on failed upgrade:
  15. #    <old-preinst> abort-upgrade <new-version>
  16.  
  17.  
  18. # Prepare to remove a no-longer used conffile
  19. prep_rm_conffile()
  20. {
  21.     CONFFILE="$1"
  22.  
  23.     if [ -e "$CONFFILE" ]; then
  24.         md5sum="`md5sum \"$CONFFILE\" | sed -e \"s/ .*//\"`"
  25.         old_md5sum="`sed -n -e \"/^Conffiles:/,/^[^ ]/{\\\\' $CONFFILE '{s/ obsolete$//;s/.* //;p}}\" /var/lib/dpkg/status`"
  26.         if [ "$md5sum" != "$old_md5sum" ]; then
  27.             echo "Obsolete conffile $CONFFILE has been modified by you, renaming to .dpkg-bak"
  28.             mv -f "$CONFFILE" "$CONFFILE".dpkg-bak
  29.     else
  30.         mv -f "$CONFFILE" "$CONFFILE".dpkg-obsolete
  31.     fi
  32.     fi
  33. }
  34.  
  35. # Prepare to move a conffile without triggering a dpkg question
  36. prep_mv_conffile() {
  37.     CONFFILE="$1"
  38.  
  39.     if [ -e "$CONFFILE" ]; then
  40.         md5sum="`md5sum \"$CONFFILE\" | sed -e \"s/ .*//\"`"
  41.         old_md5sum="`sed -n -e \"/^Conffiles:/,/^[^ ]/{\\\\' $CONFFILE '{s/ obsolete$//;s/.* //;p}}\" /var/lib/dpkg/status`"
  42.         if [ "$md5sum" = "$old_md5sum" ]; then
  43.             mv -f "$CONFFILE" "$CONFFILE".dpkg-bak
  44.     else
  45.             mv -f "$CONFFILE" "$CONFFILE".dpkg-moving
  46.         fi
  47.     fi
  48. }
  49.  
  50.  
  51. # Prepare to rename the persistent-disk.rules file
  52. prep_mv_persistent_disk_rules()
  53. {
  54.     prep_mv_conffile /etc/udev/rules.d/65-persistent-disk.rules \
  55.                  /etc/udev/rules.d/65-persistent-storage.rules
  56. }
  57.  
  58. # Prepare to rename the cdrom_id.rules file
  59. prep_mv_cdrom_id_rules()
  60. {
  61.     prep_mv_conffile /etc/udev/rules.d/50-cdrom_id.rules \
  62.                  /etc/udev/rules.d/30-cdrom_id.rules
  63. }
  64.  
  65.  
  66. case "$1" in
  67.     install|upgrade)
  68.     # Upgrade from dapper
  69.     if dpkg --compare-versions "$2" lt "093-0ubuntu1"; then
  70.         prep_mv_persistent_disk_rules
  71.     fi
  72.  
  73.     # Upgrade within feisty development cycle
  74.     if dpkg --compare-versions "$2" lt "108-0ubuntu1"; then
  75.         prep_mv_cdrom_id_rules
  76.     fi
  77.     ;;
  78.  
  79.     abort-upgrade)
  80.     ;;
  81.  
  82.     *)
  83.     echo "$0 called with unknown argument \`$1'" 1>&2
  84.     exit 1
  85.     ;;
  86. esac
  87.  
  88.  
  89. exit 0
  90.